package com.example.aslongastoday.ui.tomato_clock;

import android.app.Service;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Binder;
import android.os.IBinder;

import com.example.aslongastoday.R;

import org.jetbrains.annotations.Nullable;

public class BackgroundMusicService extends Service {
    public MediaPlayer mediaPlayer;
    private final IBinder musicBinder = (IBinder) new LocalBinder();
    public BackgroundMusicService() {
    }

    public class LocalBinder extends Binder{
        BackgroundMusicService getService() {
            return BackgroundMusicService.this;
        }
    }

//    @Override
//    public void onCreate(){
//        super.onCreate();
//        mediaPlayer = MediaPlayer.create(this, R.raw.thanks_music);
//        mediaPlayer.setLooping(true);
//    }
    @Override
    public void onDestroy() {
        super.onDestroy();
        if (mediaPlayer != null) {
            mediaPlayer.stop();
            mediaPlayer.release();
            mediaPlayer = null;
        }
    }


    @Override
    public IBinder onBind(Intent intent) {
        return musicBinder;
    }

}